import type { AddressParams } from '@/types/address'
import type { AddressItem } from '@/types/goods'
import { myGet, myPost, myRequest } from '@/utils/request'

/** 获取地址列表 */
export const getAddressListAPI = () => {
  return myGet<AddressItem[]>('/member/address')
}

/** 新增地址 */
export const postMemberAddressAPI = (data: AddressParams) => {
  return myPost('/member/address', data)
}

/** 地址详情 */
export const getAddressDetailAPI = (id: string) => {
  return myGet<AddressItem>(`/member/address/${id}`)
}

/** 编辑地址 */
export const putMemberAddressAPI = (id: string, data: AddressParams) => {
  return myRequest({
    method: 'PUT',
    url: `/member/address/${id}`,
    data
  })
}

/** 删除地址 */
export const deleteMemberAddressAPI = (id: string) => {
  return myRequest({
    method: 'DELETE',
    url: `/member/address/${id}`
  })
}
